<?php View::render('admin/layouts/meta');?>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span> 项目管理
    <span class="c-gray en">&gt;</span> 分类列表
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
        <i class="Hui-iconfont">&#xe68f;</i>
    </a>
</nav>
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
            <a href="javascript:;" onclick="formAlert('添加分类','<?php echo Router::getBaseUrl(); ?>/admin_goods/categoryEdit', '80%','80%')" class="btn btn-primary radius">
                <i class="Hui-iconfont">&#xe600;</i> 添加分类
            </a>
        </span>
        <span class="r">共有数据：<strong><?php echo count($list); ?></strong> 条</span>
    </div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
            <tr class="text-c">
                <th width="50">ID</th>
                <th width="150">分类名称</th>
                <th width="150">类型</th>
                <th width="150">排序</th>
                <th width="150">添加时间</th>
                <th width="150">更新时间</th>
<!--                <th width="200">操作</th>-->
            </tr>
            </thead>
            <tbody>
            <?php if ($list) {
                foreach ($list as $info) {
                    ?>
                    <tr class="text-c">
                        <td><?php echo $info['category_id']; ?></td>
                        <td class="text-l"><?php echo $info['name']; ?></td>
                        <td><?php if ($info['categral']==1){echo "豪程大学";}elseif($info['categral']==2){echo  "线下项目";}else{echo "子类";} ?></td>
                        <td><?php echo $info['sort']; ?></td>
                        <td><?php echo $info['add_time']; ?></td>
                        <td><?php echo $info['update_time']; ?></td>

                    </tr>
                    <?php if ($info['child']) {
                        foreach ($info['child'] as $item) {
                            ?>
                            <tr class="text-c">
                                <td><?php echo $item['category_id']; ?></td>
                                <td class="text-l">|---- <?php echo $item['name'].$info['categral']; ?></td>
                                <td><?php if ($item['categral']==1){echo "豪程大学";}elseif($item['categral']==2){echo  "线下项目";}else{echo "子类";} ?></td>
                                <td><?php echo $item['sort']; ?></td>
                                <td><?php echo $item['add_time']; ?></td>
                                <td><?php echo $item['update_time']; ?></td>

                            </tr>
                            <?php if ($item['child']) {
                                foreach ($item['child'] as $cell) {?>
                                    <tr class="text-c">
                                        <td><?php echo $cell['category_id']; ?></td>
                                        <td class="text-l">|-------- <?php echo $cell['name']; ?></td>
                                        <td><?php echo $cell['sort']; ?></td>
                                        <td><?php echo $cell['add_time']; ?></td>
                                        <td><?php echo $cell['update_time']; ?></td>

                                    </tr>
                                <?php }}}}}}?>
            </tbody>
        </table>
    </div>
</div>
</body>
<?php View::render('admin/layouts/footer');?>
<script type="text/javascript">
    $(function(){
        window.formAlert = function(title, url, w, h) {
            layer.open({
                type: 2,
                title: title,
                area: [w, h],
                content: url,
                end: function(){
                    window.location.href=location.href;
                }
            });
        }
        $('.j_del').click(function(){
            var id = $(this).attr('rel');
            var type=$(this).attr('chile');
            if(type==3){
                var r=confirm("是否确认删除？");
            }else{
                var r=confirm("删除后,子分类将一同删除!");
            }

            if (r==true) {
                $.post('<?php echo Router::getBaseUrl(); ?>/admin_goods/categoryDelete', {categoryId: id}, function (result) {
                    if (result.status == 200) {
                        layer.msg(result.msg, {
                            icon: 1,
                            skin: 'u-msg',
                            time: 1800,
                        }, function () {
                            window.location.href = location.href;
                            return true;
                        });
                    } else {
                        layer.msg(result.msg, {
                            icon: 0,
                            skin: 'u-msg',
                            time: 2200,
                        });
                    }
                }, 'json');
            }
            return;
        });
    });
</script>
</html>